<style>
  .tpl .content-left{
    width: 120px;
    float: left;
  }
  .tpl .content-right{
    /*width: calc(100% - 140px);*/
    /*float: right;*/
  }
</style>
<template>
  <main class="tpl">
    <section class="clearfix">
      <!--<section class="content-box content-left">-->
        <!--<article style="min-height: auto" @click="update(1,modals[1])">-->
          <!--<models :data.sync="modals[1]"></models>-->
        <!--</article>-->
      <!--</section>-->
      <section  class="content-box content-right" style="width: 100%">
        <article style="min-height: auto" @click="update(0,modals[0])">
          <models :data.sync="modals[0]"></models>
        </article>
      </section>
    </section>
  </main>
</template>

<script>
import tpl from './tplmixin'

export default {
  data () {
    return {
      modals: [
        {
          types:'',
          title:'',
          html:'<p class="text-center">填写内容</p>',
          img:'',
          type:6
        },
//        {
//          type:'list',
//          types:'',
//          title:'',
//          class:'',
//          disable:true
//        }
      ],
      param:{
        "content": "",
        "displayOrder": 0,
        "enabled": true,
        "langKey": "",
        "name": "",
        "templateId": 0,
        "templateName": "",
        "url": "",
        "websiteId": 0,
        "websiteName": ""
      }
    }
  },
  methods:{
    getDetail () {
      let vm = this
      this.$http.get('cms/api/pages/'+vm.$route.query.id,{}).then(function(res){
        vm.param = res.data
        vm.modals[0].title = res.data.name
        vm.modals[0].html = res.data.content
      })
    },
    sub () {
      let vm = this
      vm.param.name = vm.modals[0].title
      vm.param.content = vm.modals[0].html
      this.$http.put('cms/api/pages',Object.assign({id:vm.$route.query.id},vm.param)).then(function(res){
        vm.getDetail()
      })
    },
    see () {
      window.open('http://118.242.0.43:7060/detail.html?id='+this.$route.query.menuId+'&productId='+this.$route.query.id)
    }
  },
  mounted () {
    this.getDetail()
    let vm = this
    this.$parent.$parent.sub = vm.sub
    this.$parent.$parent.see = vm.see
  },
  mixins:[tpl],

}

</script>
